//
//  CollectionHeaderView.swift
//  DouYuZB
//
//  Created by James on 2017/10/15.
//  Copyright © 2017年 James. All rights reserved.
//

import UIKit
import SDWebImage

class CollectionHeaderView: UICollectionReusableView {
    
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var iconImageView: UIImageView!
    
    @IBOutlet weak var moreButton: UIButton!
    
    
    var group: AnchorGroup? {
        didSet{
             
            titleLabel.text = group?.tag_name
            
//            let imgName = group?.icon_url
            let imgName = group?.small_icon_url
            print("name:\(titleLabel.text ) -- > \(imgName)")
            if imgName?.contains("https:") == true{

                sd_internalSetImage(with: URL(string: imgName!), placeholderImage: UIImage(named:"home_header_normal"), options: [], operationKey: nil, setImageBlock: { (image, data) in
                    self.iconImageView.image = image
                }, progress: nil, completed: { (_, erro, type, url) in
                    
                })
            }else {
                guard let sectionName = group?.tag_name else{
                    iconImageView.image = UIImage(named:"home_header_normal")
                    return
                }
                if sectionName == "颜值" {
                    iconImageView.image = UIImage(named:"home_header_normal")
                }else if sectionName == "热门"{
                    iconImageView.image = UIImage(named:"home_header_hot")
                }
                
                
            }
            
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    
}
